library(survival)
data<-read.table("input_expr",sep="\t",head=T)
data<-data["6909",]
data
clin<-read.table("combined_clinical.txt",sep="\t",head=T)
dim(clin)
dim(data)
clin[1,]
data<-t(data)
dim(data)
data[1:4,]
dim9data)
dim(data)
colnames(data)<-"GSMID"
merge<-(data,clin,by="GSMID")
merge<-merge(data,clin,by="GSMID")
dim(merge)
data[1,]
rownames<-rownames(data)
rownames[1:5]
data<-cbind(rownames,data)
colnames(data)<-c("GSMID","EXPR")
merge<-merge(data,clin,by="GSMID")
dim(merge)
clin<-read.table("combined_clinical.txt",sep="\t",head=T)
merge<-merge(data,clin,by="GSMID")
dim(merge)
data<-read.table("input_expr",sep="\t")
data<-read.table("temp",sep="\t")
dim(data)
data<-t(data)
dim(data)
data[1,]
data<-read.table("temp",sep="\t",head=T)
data[1,1:5]
colnames<-colnames(data)
data<-cbind(colnames,data)
dim(data)
data<-read.table("temp",sep="\t",head=T)
colnames<-colnames(data)
data<-rbind(colnames,data)
dim(data)
data<-t(data)
dim(data)
data[1,]
colnames(data)<-c("GSMID","EXPR")
merge<-merge(data,clin,by="GSMID")
dim(merge)
merge[1,]
which(is.na(data$RFSEVENT))
is.na(data$RFSEVENT)
is.na(merge$RFSEVENT)
which(is.na(merge$RFSEVENT))
dim(merge)
merge[1,]
merge_filetered<-merge
merge_filetered<-merge_filetered[which(is.na(merge$RFSEVENT)),]
which(is.na(merge_filetered$RFSEVENT))
merge_filetered[1,]
merge[1,]
merge_filetered<-merge
merge_filetered<-merge_filetered[which(!is.na(merge$RFSEVENT)),]
which(is.na(merge_filetered$RFSEVENT))
merge_filetered<-merge_filetered[which(!is.na(merge$RFSTIME)),]
merge_filetered<-merge
merge_filetered<-merge_filetered[which(!is.na(merge_filetered$RFSEVENT)),]
 merge_filetered<-merge_filetered[which(!is.na(merge_filetered$RFSTIME)),]
merge_filetered$RFSEVENT<-as.factor(merge_filetered$RFSEVENT)
merge_filetered$RFSTIME<-as.numeric(merge_filetered$RFSTIME)
merge_filetered[1,]
fit1 <- coxph(Surv(RFSTIME,RFSEVENT) ~ EXPR,data=merge_filetered)
merge_filetered$RFSEVENT<-as.numeric(merge_filetered$RFSEVENT)
merge_filetered$EXPR<-as.numeric(merge_filetered$EXPR)
fit <- coxph(Surv(RFSTIME,RFSEVENT) ~ EXPR,data=merge_filetered)
fit
merge_filetered[1,]
table( merge_filetered$ERSTATUS)
 merge_filetered_er1<- merge_filetered[which(merge_filetered$ERSTATUS==1),]
 merge_filetered_er0<- merge_filetered[which(merge_filetered$ERSTATUS==0),]
dim( merge_filetered_er0)
dim( merge_filetered_er1)
ls()
dim(data)
data[1,]
rownames(data)[1:4]
gse1456<-read.table("GSE1456_doc.txt",sep="\t",head=T)
dim(gse1456)
gse1456[1,]
merge1456<-merge(gse1456,data,by='GSMID')
dim(merge1456)
table(gse1456$RFSTIME)
gse1456$RFSTIME<-as.numeric(gse1456$RFSTIME)
merge1456[1,]
merge1456$RFSTIME<-as.numeric(merge1456$RFSTIME)
merge1456$EXPR<-as.numeric(merge1456$EXP)
pdf("scatterplot.pdf")
plot(merge1456$RFSTIME,merge1456$EXPR,main="GSE1456",xlab=c("RFSTIME"),ylab=c("EXPR"))
dev.off()
 merge1456[1,]
gse1456[1,]
merge1456<-merge(gse1456,data,by='GSMID')
pdf("scatterplot.pdf")
merge1456<-merge(gse1456,data,by='GSMID')
dev.off()
pdf("scatterplot.pdf")
plot(merge1456$RFSTIME,merge1456$EXPR,main="GSE1456",xlab=c("RFSTIME"),ylab=c("EXPR"))
dev.off()
merge1456[1,]
summary(merge1456$EXPR)
merge1456[1,6]
gse1456<-read.table("GSE1456_doc.txt",sep="\t",head=T,stringsAsFactors =TRUE)
merge1456<-merge(gse1456,data,by='GSMID')
merge1456[1,]
pdf("scatterplot.pdf")
plot(merge1456$RFSTIME,merge1456$EXPR,main="GSE1456",xlab=c("RFSTIME"),ylab=c("EXPR"))
dev.off()
merge1456[1,6]
gse1456<-read.table("GSE1456_doc.txt",sep="\t",head=T,stringsAsFactors =FALSE)
merge1456<-merge(gse1456,data,by='GSMID')
merge1456[1,6]
is.factor(merge1456$EXPR)
gse1456<-read.table("GSE1456_doc.txt",sep="\t",head=T,colClasses=c("character","character","factor","numeric","factor","numeric"))
gse1456<-read.table("GSE1456_doc.txt",sep="\t",head=T,colClasses=c("character","character","factor","numeric","factor"))
data[1,]
data1<-data
data1[1,]
data1$EXPR<-as.numeric(levels(data1$EXPR)[data1$EXPR])
 data1$EXPR[1]
names(data1)
colnames(data1)<-c("GSMID","EXPR")
data1$EXPR<-as.numeric(levels(data1$EXPR)[data1$EXPR])
 data1$EXPR[1]
names(data1)
names(data1)<-c("GSMID","EXPR")
names(data1)
dim(data1)
data1[1,]
is.factor(data$EXPR)
is.factor(data1$EXPR)
data[1,]
as.numeric(data[1,2])
data1[,2]<-as.numeric(data1[,2])
data1[1,2]
colnames(data1)
merge1456<-merge(gse1456,data1,by='GSMID')
 merge1456[1,]
summary(merge1456$EXPR)
merge1456[1,6]
merge1456$EXPR<-as.numeric(levels(merge1456$EXPR)[merge1456$EXPR])
summary(merge1456$EXPR)
pdf("scatterplot.pdf")
plot(merge1456$RFSTIME,merge1456$EXPR,main="GSE1456",xlab=c("RFSTIME"),ylab=c("EXPR"))
dev.off()
pdf("scatterplot.pdf")
plot(merge1456$RFSTIME,merge1456$EXPR,main="GSE1456",xlab=c("RFSTIME"),ylab=c("EXPR"))
abline(lm(merge1456$EXPR~merge1456$RFSTIME), col="red")
dev.off()

#code for plot pdf scatter
data2<-probeset[4,2:ncol(probeset)]
data2<-rbind(colnames[1:length(colnames)],data2)
data2<-t(data2)
colnames(data2)<-c("GSMID","EXPR")

gse1456<-read.table("GSE1456_doc.txt",sep="\t",head=T,colClasses=c("character","character","factor","numeric","factor"))
merge1456<-merge(gse1456,data2,by='GSMID')
merge1456$EXPR<-as.numeric(levels(merge1456$EXPR)[merge1456$EXPR])
gse17705<-read.table("GSE17705_doc.txt",sep="\t",head=T,colClasses=c("character","character","factor","numeric","factor"))
merge17705<-merge(gse17705,data2,by='GSMID')
merge17705$EXPR<-as.numeric(levels(merge17705$EXPR)[merge17705$EXPR])
gse2990<-read.table("GSE2990_doc.txt",sep="\t",head=T,colClasses=c("character","character","factor","numeric","factor"))
merge2990<-merge(gse2990,data2,by='GSMID')
merge2990$EXPR<-as.numeric(levels(merge2990$EXPR)[merge2990$EXPR])
gse4922<-read.table("GSE4922_doc.txt",sep="\t",head=T,colClasses=c("character","character","factor","numeric","factor"))
merge4922<-merge(gse4922,data2,by='GSMID')
merge4922$EXPR<-as.numeric(levels(merge4922$EXPR)[merge4922$EXPR])
gse7390<-read.table("GSE7390_doc.txt",sep="\t",head=T,colClasses=c("character","character","factor","numeric","factor"))
merge7390<-merge(gse7390,data2,by='GSMID')
merge7390$EXPR<-as.numeric(levels(merge7390$EXPR)[merge7390$EXPR])
pdf("scatterplot_205993_s_at_event.pdf")
color<-gsub("1","red",merge1456$RFSEVENT)
color<-gsub("0","green",color)
plot(merge1456$RFSTIME,merge1456$EXPR,main="GSE1456",xlab=c("RFSTIME"),ylab=c("EXPR"),col=color)
 abline(lm(merge1456$EXPR~merge1456$RFSTIME), col="red")
color<-gsub("1","red",merge17705$RFSEVENT)
color<-gsub("0","green",color)
plot(merge17705$RFSTIME,merge17705$EXPR,main="GSE17705",xlab=c("RFSTIME"),ylab=c("EXPR"),col=color)
 abline(lm(merge17705$EXPR~merge17705$RFSTIME), col="red")
color<-gsub("1","red",merge2990$RFSEVENT)
color<-gsub("0","green",color)
plot(merge2990$RFSTIME,merge2990$EXPR,main="2990",xlab=c("RFSTIME"),ylab=c("EXPR"),col=color)
 abline(lm(merge2990$EXPR~merge2990$RFSTIME), col="red")
color<-gsub("1","red",merge4922$RFSEVENT)
color<-gsub("0","green",color)
plot(merge4922$RFSTIME,merge4922$EXPR,main="4922",xlab=c("RFSTIME"),ylab=c("EXPR"),col=color)
 abline(lm(merge4922$EXPR~merge4922$RFSTIME), col="red")
color<-gsub("1","red",merge7390$RFSEVENT)
color<-gsub("0","green",color)
plot(merge7390$RFSTIME,merge7390$EXPR,main="7390",xlab=c("RFSTIME"),ylab=c("EXPR"),col=color)
 abline(lm(merge7390$EXPR~merge7390$RFSTIME), col="red")
dev.off()


#rcode for survival fit
probeset[,1]
data2<-probeset[1,2:ncol(probeset)]
data2<-rbind(colnames[1:length(colnames)],data2)
data2<-t(data2)
colnames(data2)<-c("GSMID","EXPR")
merge_pbs<-merge(data2,clin,by="GSMID")
merge_pbs<-merge_pbs[which(!is.na(merge_pbs$RFSEVENT)),]
merge_pbs<-merge_pbs[which(!is.na(merge_pbs$RFSTIME)),]
#merge_pbs$RFSEVENT<-as.numeric(levels(merge_pbs$RFSEVENT)[merge_pbs$RFSEVENT])
#merge_pbs$RFSTIME<-as.numeric(levels(merge_pbs$RFSTIME)[merge_pbs$RFSTIME])
merge_pbs$EXPR<-as.numeric(levels(merge_pbs$EXPR)[merge_pbs$EXPR])
merge_pbs_er1<-merge_pbs[which(merge_pbs$ERSTATUS==1),]
merge_pbs_er0<-merge_pbs[which(merge_pbs$ERSTATUS==0),]
fit <- coxph(Surv(RFSTIME,RFSEVENT) ~ EXPR,data=merge_pbs)
#code for sub classess
#samples_class1<-gsa[which(gsa[,1]==2),]
#samples_class2<-gsa[which(gsa[,2]==2),]
#samples_class3<-gsa[which(gsa[,2]==3),]
#samples_class4<-gsa[which(gsa[,2]==4),]
#samples_class5<-gsa[which(gsa[,2]==5),]
merge_pbs_class1<-merge_pbs[samples_class1[,1],]
merge_pbs_class2<-merge_pbs[samples_class2[,1],]
merge_pbs_class3<-merge_pbs[samples_class3[,1],]
merge_pbs_class4<-merge_pbs[samples_class4[,1],]
merge_pbs_class5<-merge_pbs[samples_class5[,1],]
fit <- coxph(Surv(RFSTIME,RFSEVENT) ~ EXPR,data=merge_pbs_class1)

#code for sub classess
fit <- coxph(Surv(RFSTIME,RFSEVENT) ~ EXPR,data=merge_pbs_er0)
fit <- coxph(Surv(RFSTIME,RFSEVENT) ~ EXPR,data=merge_pbs_er1)
savehistory("Script.R")
